<template>
  <div id="app">
		<Header></Header>
		<div style="width: 80%; margin: 0 auto; margin-top: 2rem;">
			<Navigation></Navigation>
		</div>
		<div style="width: 80%; margin: 0 auto;">
			<router-view/>
		</div>
  </div>
</template>

<script>
	import Header from '@/components/Home/Header.vue'
	import Navigation from '@/components/Home/Navigation.vue'
	import NewBooks from '@/components/Home/NewBooks.vue'
	
	export default {
		name:'App',
		components: {
		Header,
		Navigation,
		NewBooks,
		},
		created() {
			// 本地储存的用户
			let local_user = window.localStorage.getItem('user');
			// 当前登录的用户名
			let active_user = this.$store.state.logreg.active_user;
			// 检测本地持久化登录
			// 如果本地存储有用户，而当前登录用户没有,则自动登录
			if(local_user && active_user == ''){
				this.$store.commit('cart/add_user', {username: local_user});
				this.$store.commit('logreg/setactive_user', local_user);
			}
		},
		mounted(){
			// 禁止复制头文字
			document.getElementsByClassName('cart')[0].onselectstart = function(){return false}
		}
	}
</script>

<style>
	* {
		padding: 0;
		margin: 0;
	}
	body {

		font: 16px -apple-system,BlinkMacSystemFont,Helvetica Neue,Helvetica,Arial,PingFang SC,Hiragino Sans GB,Microsoft YaHei,sans-serif;
		background-color: black;
	}
	
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #FFFFFF;
  width: 100%;
  min-width: 1300px;
	background-image: url(./assets/blackbgimg.jpg);
	background-repeat:  repeat-y;
	background-size: 100%;
}
.router-link-active {
	border-bottom: solid white 0.3rem;
	
}

</style>
